import { createSlice, PayloadAction } from '@reduxjs/toolkit';

interface MenuState {
  visibleMenus: {
    [key: string]: boolean;
  };
}

const initialState: MenuState = {
  visibleMenus: {
    home: true,
    chat: true,
    trend: true,
    report: true,
    knowledge: true,
    'tech-insight': true
  }
};

const menuSlice = createSlice({
  name: 'menu',
  initialState,
  reducers: {
    toggleMenu: (state, action: PayloadAction<{ key: string; visible: boolean }>) => {
      const { key, visible } = action.payload;
      state.visibleMenus[key] = visible;
    }
  }
});

export const { toggleMenu } = menuSlice.actions;
export default menuSlice.reducer; 